<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 私有成员；只能在类的内部使用不能在类的外部使用；
      let obj = {
        name: "张三",
        age: 20,
        [Symbol("weight")]: "100kg",
      };
      function Person() {
        this.name = "张三";
        this.age = 20;
        var _weight = "100kg";
      }
      let zhangsan = new Person();
      console.log(zhangsan.age);
      console.log(zhangsan.name);
      console.log(zhangsan._weight);
      // ES6 修饰符 # 代表私有成员
      // 公有   私有；
      // 私有成员：私有属性  和私有方法；
      // __proto__

      class Person {
        #weight = "100kg"; //私有属性
        // name = "张三";
        constructor() {
          // this.name = "张三";
          this.name = "张三";
          this.age = 20;
        }
        // 公有方法调用私有属性；
        getWeight() {
          console.log(this.#weight); //内部调用
        }
        #fn() {
          console.log("我是私有方法fn");
        }
        getFn() {
          this.#fn();
        }
      }

      let zhangsan = new Person();
      console.log(zhangsan);
      // console.log(zhangsan.#weight);

      zhangsan.getWeight();
      // zhangsan.#fn();
      zhangsan.getFn();
    </script>
  </body>
</html>
